package com.sc.passbook.utils;

import com.sc.passbook.vo.FeedBack;
import com.sc.passbook.vo.GainPassTemplateRequest;
import com.sc.passbook.vo.PassTemplate;
import org.apache.commons.codec.digest.DigestUtils;

/**
 * @author sc
 * Created on  2018/9/1
 */
public class RowKeyGen {
    public static String genPassTemplateRowKey(PassTemplate passTemplate){
        String info= String.valueOf(passTemplate.getId())+"_"+passTemplate.getTitle();
        return DigestUtils.md5Hex(info);
    }

    public static String genFeedBackRowKey(FeedBack feedBack){
        return new StringBuilder(String.valueOf(feedBack.getUserId())).reverse().append(Long.MAX_VALUE-System.currentTimeMillis()).toString();
    }

    public static String genPassRowKey(GainPassTemplateRequest request){
        return new StringBuilder(String.valueOf(request.getUserId())).reverse().append(Long.MAX_VALUE-System.currentTimeMillis()).append(genPassTemplateRowKey(request.getPassTemplate())).toString();
    }
}
